package com.hoyue.exam.service.impl;

import com.hoyue.classroom.service.BaseService;
import com.hoyue.MapperUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author SiMan
 * @date 2019/8/28 0:20
 */

@Service
public abstract class BaseServiceImpl<T> implements BaseService<T> {

	@Autowired
	protected MapperUtil<T> mapper;
	@Override
	public T selectByPrimaryKey(Object key) {
		return mapper.selectByPrimaryKey(key);
	}

	@Override
	public int insert(T entity) {
		return mapper.insert(entity);
	}

	@Override
	public int insertSelective(T entity) {
		return mapper.insertSelective(entity);
	}

	@Override
	public int delete(Object key) {
		return mapper.deleteByPrimaryKey(key);
	}

	@Override
	public int update(T entity) {
		return mapper.updateByPrimaryKey(entity);
	}

	@Override
	public int updateNotNull(T entity) {
		return mapper.updateByPrimaryKeySelective(entity);
	}

	@Override
	public List<T> select(T entity) {
		return mapper.select(entity);
	}

	@Override
	public List<T> selectAll() {
		return mapper.selectAll();
	}
}
